import request from '@/utils/request'

// 查询商品管理列表
export function listGoods(query) {
  return request({
    url: '/goods/goods/list',
    method: 'get',
    params: query
  })
}

// 查询商品管理详细
export function getGoods(id) {
  return request({
    url: '/goods/goods/' + id,
    method: 'get'
  })
}

// 上/下架
export function changeGoodsStatus(id, status) {
  const data = {
    id,
    status
  }
  return request({
    url: '/goods/goods/changeStatus',
    method: 'put',
    data: data
  })
}

// 批量上/下架
export function batchChangeGoodsStatus(goodsIds,status) {
  const data = {
    goodsIds,
    status
  }
  return request({
    url: '/goods/goods/batchChangeGoodsStatus',
    method: 'put',
    data: data
  })
}

// 新增商品管理
export function addGoods(data) {
  return request({
    url: '/goods/goods',
    method: 'post',
    data: data
  })
}

// 修改商品管理
export function updateGoods(data) {
  return request({
    url: '/goods/goods',
    method: 'put',
    data: data
  })
}
// 修改商品价格/库存
export function updateGoodsPriceStock(data) {
  return request({
    url: 'goods/goods/editPriceStock',
    method: 'put',
    data: data
  })
}

// 删除商品管理
export function delGoods(id) {
  return request({
    url: '/goods/goods/' + id,
    method: 'delete'
  })
}

// 导出商品管理
export function exportGoods(query) {
  return request({
    url: '/goods/goods/export',
    method: 'get',
    params: query
  })
}
